package com.sr.recitewords.common.req;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class PageResult implements Serializable {

    private static final long serialVersionUID = -5659016998688428992L;

    private List<?> list;

    private int size;

    private int pageIndex;

    private int pageCount;

    private int totalPage;

    public PageResult() {
    }

    public List<?> getList() {
        return list;
    }

    public void setList(List<?> list) {
        this.list = list;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public PageResult(List<?> list, int size, Integer pageIndex, Integer pageCount) {

        this.size = size;
        if (list != null) {
            this.list = list;
        }
        else {
            this.list = new ArrayList<>();
        }

        if (null != pageCount) {
            this.pageIndex = pageIndex;
            this.pageCount = pageCount;
            if (size % pageCount != 0) {
                totalPage = size / pageCount + 1;
            }
            else {
                totalPage = size / pageCount;
            }
        }

    }

}
